<?php

namespace App\Http\Controllers;

use App\Models\CapitalFlow;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;

class CapitalFlowController extends Controller
{
    /**
     * 列表
     * GET /api/capital-flow
     * @param Request $request
     * @return JsonResponse
     */
    public function index(Request $request): JsonResponse
    {
        $params = $request->all();
        if (empty($params['customer_id'])) {
            return response()->json(['status' => 0, 'message' => '客户ID不存在']);
        }
        if (empty($params['balance_type'])) {
            return response()->json(['status' => 0, 'message' => '资金类型不能为空']);
        }

        $capitalFlow = new CapitalFlow();
        $params['status'] = 'ENABLE';
        $data = $capitalFlow->getList($params);

        return response()->json(['status' => 1, 'data' => $data]);
    }
}
